let gameDao = module.exports;
let util = require('util');
let mysqlPool = require('./MySQLPool');

gameDao.queryPage = async function(uid, page){
    let sql = 'select id, changeCoin, gameType, utime from win_lost_record where uid = ? ' +
        'order by utime desc';
    let pageIndex = (page-1) * 10;
    sql += " limit ?, 10";
    let args = [uid, pageIndex];
    let res = await mysqlPool.query(sql, args);
    if (res){
        return res;
    }

    return [];
};

gameDao.queryPageCnt = async function (uid) {
    let sql = 'select count(1) cnt from win_lost_record where uid = ?';
    let args = [uid];
    let res = await mysqlPool.query(sql, args);
    if (res){
        return res[0].cnt;
    }

    return 0;
};